package com.ruoyi.flow.flow.identity;

import com.ruoyi.flow.flow.workflow.FlowService;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * Created by fenghuo on 2018/8/23.
 */
@RestController
@RequestMapping("/flow/identities")
public class IdentityController {

    /**
     * 获取全部用户
     *
     * @return
     */
    @RequestMapping(value = "/users", method = RequestMethod.GET)
    public List<User> getUsers(@RequestParam Optional<String> groupId) {
        return FlowService.identityService().getUsers(groupId.get(), null);
    }

    /**
     * 获取全部用户组
     *
     * @return
     */
    @RequestMapping(value = "/groups", method = RequestMethod.GET)
    public List<Group> getGroups() {
        return FlowService.identityService().getGroups();
    }
}
